package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.YxxUtilityPayments;
import com.ruoyi.system.service.IYxxUtilityPaymentsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 水电费缴费记录Controller
 * 
 * @author ruoyi
 * @date 2025-03-10
 */
@RestController
@RequestMapping("/system/payments")
public class YxxUtilityPaymentsController extends BaseController
{
    @Autowired
    private IYxxUtilityPaymentsService yxxUtilityPaymentsService;

    /**
     * 查询水电费缴费记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:payments:list')")
    @GetMapping("/list")
    public TableDataInfo list(YxxUtilityPayments yxxUtilityPayments)
    {
        startPage();
        List<YxxUtilityPayments> list = yxxUtilityPaymentsService.selectYxxUtilityPaymentsList(yxxUtilityPayments);
        return getDataTable(list);
    }

    /**
     * 导出水电费缴费记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:payments:export')")
    @Log(title = "水电费缴费记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YxxUtilityPayments yxxUtilityPayments)
    {
        List<YxxUtilityPayments> list = yxxUtilityPaymentsService.selectYxxUtilityPaymentsList(yxxUtilityPayments);
        ExcelUtil<YxxUtilityPayments> util = new ExcelUtil<YxxUtilityPayments>(YxxUtilityPayments.class);
        util.exportExcel(response, list, "水电费缴费记录数据");
    }

    /**
     * 获取水电费缴费记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:payments:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(yxxUtilityPaymentsService.selectYxxUtilityPaymentsById(id));
    }

    /**
     * 新增水电费缴费记录
     */
    @PreAuthorize("@ss.hasPermi('system:payments:add')")
    @Log(title = "水电费缴费记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YxxUtilityPayments yxxUtilityPayments)
    {
        return toAjax(yxxUtilityPaymentsService.insertYxxUtilityPayments(yxxUtilityPayments));
    }

    /**
     * 修改水电费缴费记录
     */
    @PreAuthorize("@ss.hasPermi('system:payments:edit')")
    @Log(title = "水电费缴费记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YxxUtilityPayments yxxUtilityPayments)
    {
        return toAjax(yxxUtilityPaymentsService.updateYxxUtilityPayments(yxxUtilityPayments));
    }

    /**
     * 删除水电费缴费记录
     */
    @PreAuthorize("@ss.hasPermi('system:payments:remove')")
    @Log(title = "水电费缴费记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yxxUtilityPaymentsService.deleteYxxUtilityPaymentsByIds(ids));
    }
}
